<div class="card">
	<div class="card-header">
		<i class="fas fa-filter"></i> {{ heading_title }}
		<div class="float-end">
			<button type="button" id="button-reset" data-loading-text="{{ text_loading }}" class="btn btn-danger btn-sm"><i class="fas fa-sync"></i> {{ button_reset }}</button>
		</div>
	</div>
	<div class="card-body">
		<div class="table-responsive">
			<table class="table table-bordered">
				<thead>
					<tr>
						<td class="text-start">{{ column_name }}</td>
						<td class="text-start">{{ column_model }}</td>
						<td class="text-end">{{ column_viewed }}</td>
						<td class="text-end">{{ column_percent }}</td>
					</tr>
				</thead>
				<tbody>
					{% if products %}
						{% for product in products %}
							<tr>
								<td class="text-start">{{ product.name }}</td>
								<td class="text-start">{{ product.model }}</td>
								<td class="text-end">{{ product.viewed }}</td>
								<td class="text-end">{{ product.percent }}</td>
							</tr>
						{% endfor %}
					{% else %}
						<tr>
							<td class="text-center" colspan="4">{{ text_no_results }}</td>
						</tr>
					{% endif %}
				</tbody>
			</table>
		</div>
		<div class="row">
			<div class="col-sm-6 text-start">{{ pagination }}</div>
			<div class="col-sm-6 text-end">{{ results }}</div>
		</div>
	</div>
</div>
<script type="text/javascript"><!--
$('#button-reset').on('click', function() {
    $.ajax({
        url: 'index.php?route=extension/opencart/report/product_viewed|reset&user_token={{ user_token }}',
        dataType: 'json',
        beforeSend: function() {
            $('#button-reset').button('loading');
        },
        complete: function() {
            $('#button-reset').button('reset');
        },
        success: function(json) {
            $('.alert-dismissible').remove();

            if (json['error']) {
                $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fas fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
            }

            if (json['success']) {
                $('#content > .container-fluid').prepend('<div class="alert alert-success alert-dismissible"><i class="fas fa-exclamation-circle"></i> ' + json['success'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');

                $('#report').load('index.php?route=extension/opencart/report/product_viewed|report&user_token={{ user_token }}');
            }
        },
        error: function(xhr, ajaxOptions, thrownError) {
            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
    });
});
//--></script>